<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function mygenerator(arr) {
        var num = 0;

        arr.next = function () {
          if (num < arr.length) {
            return { value: arr[num++], done: false };
          } else {
            return { value: undefined, done: true };
          }
        };
        return arr;
      }
      let arr = ["张三", "lisi", "王五"];
      let myin = mygenerator(arr);
      console.log(myin.next());
      console.log(myin.next());
      console.log(myin.next());
      console.log(myin.next());
    </script>
  </body>
</html>
